package com.camel.base.ei;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.camel.base.utils.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.UUID;

@RestController
public class WMCenterController {


    @PostMapping("/baseCenter/userOrgService/user/userId")
    public BusinessCenterResult userUserId(@RequestBody JSONObject jsonObject) {
        JSONObject object = FileUtils.readJsonFile("userUserId.json");
        return BusinessCenterResult.success(object);
    }



    @PostMapping("/baseCenter/userOrgService/users/userName")
    public BusinessCenterResult usersUserName(@RequestBody JSONObject jsonObject) {
        JSONObject object = FileUtils.readJsonFile("usersUserName.json");
        JSONArray res = object.getJSONArray("data");
        return BusinessCenterResult.success(res);
    }

    @PostMapping("/baseCenter/userOrgService/users/deptNo")
    public BusinessCenterResult usersDeptNo(@RequestBody JSONObject jsonObject) {
        JSONObject object = FileUtils.readJsonFile("usersDeptNo.json");
        JSONArray res = object.getJSONArray("data");
        return BusinessCenterResult.success(res);
    }

    @PostMapping("/baseCenter/userOrgService/users/deptNos")
    public BusinessCenterResult usersDeptNos(@RequestBody JSONObject jsonObject) {
        JSONObject object = FileUtils.readJsonFile("usersDeptNos.json");
        return BusinessCenterResult.success(object);
    }

    @PostMapping("/baseCenter/userOrgService/org/orgNo")
    public BusinessCenterResult orgOrgNo(@RequestBody JSONObject jsonObject) {
        JSONObject object = FileUtils.readJsonFile("orgOrgNo.json");
        return BusinessCenterResult.success(object);
    }

    @PostMapping("/baseCenter/userOrgService/dept/deptNo")
    public BusinessCenterResult deptDeptNo(@RequestBody JSONObject jsonObject) {
        JSONObject object = FileUtils.readJsonFile("deptDeptNo.json");
        return BusinessCenterResult.success(object);
    }

    @PostMapping("/baseCenter/userOrgService/users/orgNo")
    public BusinessCenterResult usersOrgNo(@RequestBody JSONObject jsonObject) {
        JSONObject object = FileUtils.readJsonFile("usersOrgNo.json");
        JSONArray res = object.getJSONArray("data");
        return BusinessCenterResult.success(res);
    }

    @PostMapping("/baseCenter/userOrgService/users/userNo")
    public BusinessCenterResult usersUserNo(@RequestBody JSONObject jsonObject) {
        if(jsonObject.getString("userNo").equals("GQCS")) {
            JSONObject object = FileUtils.readJsonFile("usersUserNo.json");
            JSONArray res = object.getJSONArray("data");
            return BusinessCenterResult.success(res);
        }else {
            JSONObject object = FileUtils.readJsonFile("usersUserNoP35000551.json");
            JSONArray res = object.getJSONArray("data");
            return BusinessCenterResult.success(res);
        }

    }

    @PostMapping("/baseCenter/privService/users/url")
    public BusinessCenterResult usersUrl(@RequestBody JSONObject jsonObject) {
        JSONObject object = FileUtils.readJsonFile("usersUrl.json");
        JSONArray res = object.getJSONArray("data");
        return BusinessCenterResult.success(res);
    }


}
